package com.course.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
/**
 * 后端统一返回结果
 */
public class Result<T> implements Serializable {
    private Integer code;//响应码
    private String msg;//响应信息
    private T data;//返回的数据
    public static <T>Result<T> sucess() {
        Result<T> result = new Result<T>();
        result.code = 1;
        return result;
    }
    public static <T>Result <T>sucess(T object){
        Result<T> result = new Result<T>();
        result.data = object;
        result.code = 1;
        return result;
    }
    public static <T>Result <T>error(String msg){
        Result result = new Result();
        result.msg = msg;
        result.code = 0;
        return result;
    }


}
